﻿using System;

namespace test_9_28_C_Sharp
{
    ////5-1.cs
    ////读者类
    //class Reader
    //{
    //    public string ReaderID { get; set; }
    //    public string ReaderName { get; set; }
    //    private int readerAge;
    //    public int ReaderAge
    //    {
    //        get { return readerAge; }
    //        set 
    //        {
    //            if (value > 1 && value < 120)
    //                readerAge = value;
    //        }
    //    }
    //    public void Display()
    //    {
    //        Console.WriteLine("读者证号:\t" + this.ReaderID + "\n读者姓名:\t"
    //            + this.ReaderName + "\n读者年龄:\t" + this.ReaderAge);
    //    }
    //}
    ////学生读者类 Student,集成于 Reader类
    //class Student : Reader
    //{
    //    public string classRoom { get; set; }
    //}
    ////启动类
    //class Program
    //{
    //    static void Main(string[] args)
    //    {
    //        Console.WriteLine("我是叶豪方，这是我的上机作业6");
    //        Student stu = new Student();//新建学生读者
    //        //访问继承得到的成员
    //        stu.ReaderID = "S0001";
    //        stu.ReaderName = "Tony";
    //        stu.ReaderAge = 20;
    //        stu.Display();
    //        //访问新定义的数据成员
    //        stu.classRoom = "计算机 901";
    //        Console.WriteLine("所在班级:\t" + stu.classRoom);
    //    }
    //}
    ////5-4.cs
    ////读者类 Reader
    //class Reader
    //{
    //    public string ReaderID { get; set; }
    //    public string ReaderName { get; set; }
    //    public Reader(string ReaderID, string ReaderName)
    //    {
    //        this.ReaderID = ReaderID;
    //        this.ReaderName = ReaderName;
    //        Console.WriteLine("基类 Reader 的带参构造函数被调用");
    //    }
    //}
    //class Student : Reader 
    //{
    //    public string ClassRoom { get; set; }
    //    public Student(string ReaderID, string ReaderName, string ClassRoom) :
    //    base(ReaderID, ReaderName)
    //    {
    //        this.ClassRoom = ClassRoom;
    //        Console.WriteLine("派生类的带参构造函数被调用");
    //    }
    //}
    //class Program
    //{
    //    static void Main(string[] args)
    //    {
    //        Console.WriteLine("我是叶豪方，这是我的上机作业6");
    //        Student Stu = new Student("S0001", "Hill", "计算机901");
    //        Console.WriteLine("读者证号:" + Stu.ReaderID + "\n读者姓名:" 
    //            + Stu.ReaderName + "\n所在班级:" + Stu.ClassRoom);
    //    }
    //}

    ////5-5.cs
    ////枚举类型————图书状态
    //enum EBookStatus
    //{
    //    AtLibrary,//在馆
    //    Borrowed,//出馆
    //}
    ////图书类
    //class Book
    //{
    //    public string BookID { get; set; }
    //    public string BookName { get; set; }
    //    public EBookStatus CurrentStatus { get; set; }
    //    public DateTime BorrowDate { get; set; }
    //    public DateTime ReturnDate { get; set; }
    //}
    ////读者类 Reader
    //class Reader
    //{
    //    public string ReaderID { get; set; }
    //    public string ReaderName { get; set; }
    //    public Book BoeeowedBook { get; set; }
    //    public void Display()
    //    {
    //        Console.WriteLine("读者证号:\t" + this.ReaderID + "\n所借图书信息:\n\t图书编号:" 
    //            + this.BoeeowedBook.BookID + "\n\t图书名称:" + this.BoeeowedBook.BookName 
    //            + "\n\t借书日期:" + this.BoeeowedBook.BorrowDate.ToShortDateString());
    //    }
    //    public void BorrowBook(Book book)
    //    {
    //        book.BorrowDate = DateTime.Today;
    //        book.ReturnDate = DateTime.Today.AddDays(30);
    //        this.BoeeowedBook = book;
    //        book.CurrentStatus = EBookStatus.Borrowed;
    //    }
    //}
    //class Student : Reader
    //{
    //    public new void BorrowBook(Book book)
    //    {
    //        book.BorrowDate = DateTime.Today;
    //        book.ReturnDate = DateTime.Today.AddDays(60);
    //        this.BoeeowedBook = book;
    //        book.CurrentStatus = EBookStatus.Borrowed;
    //    }
    //}
    //class Program
    //{
    //    static void Main(string[] args)
    //    {
    //        Console.WriteLine("我是叶豪方，这是我的上机作业6");
    //        Book b = new Book();
    //        b.BookID = "B0001";
    //        b.BookName = "C语言";
    //        Student Tony = new Student();
    //        Tony.ReaderID = "R0001";
    //        Tony.ReaderName = "Tony";
    //        Tony.BorrowBook(b);
    //        Tony.Display();
    //    }
    //}

    ////5-5.cs
    ////枚举类型————图书状态
    //enum EBookStatus
    //{
    //    AtLibrary,//在馆
    //    Borrowed,//出馆
    //}
    ////图书类
    //class Book
    //{
    //    public string BookID { get; set; }
    //    public string BookName { get; set; }
    //    public EBookStatus CurrentStatus { get; set; }
    //    public DateTime BorrowDate { get; set; }
    //    public DateTime ReturnDate { get; set; }
    //}
    ////读者类 Reader
    //class Reader
    //{
    //    public string ReaderID { get; set; }
    //    public string ReaderName { get; set; }
    //    public Book BoeeowedBook { get; set; }
    //    public void Display()
    //    {
    //        Console.WriteLine("读者证号:\t" + this.ReaderID + "\n所借图书信息:\n\t图书编号:"
    //            + this.BoeeowedBook.BookID + "\n\t图书名称:" + this.BoeeowedBook.BookName
    //            + "\n\t借书日期:" + this.BoeeowedBook.BorrowDate.ToShortDateString());
    //    }
    //    public virtual void BorrowBook(Book book)
    //    {
    //        book.BorrowDate = DateTime.Today;
    //        this.BoeeowedBook = book;
    //        book.CurrentStatus = EBookStatus.Borrowed;
    //    }
    //}
    //class Student : Reader
    //{
    //    public override void BorrowBook(Book book)
    //    {
    //        base.BorrowBook(book);
    //        book.ReturnDate = book.BorrowDate.AddDays(60);
    //    }
    //}
    //class Program
    //{
    //    static void Main(string[] args)
    //    {
    //        Console.WriteLine("我是叶豪方，这是我的上机作业6");
    //        Book b = new Book();
    //        b.BookID = "B0001";
    //        b.BookName = "C语言";
    //        Student Tony = new Student();
    //        Tony.ReaderID = "R0001";
    //        Tony.ReaderName = "Tony";
    //        Tony.BorrowBook(b);
    //        Tony.Display();
    //    }
    //}
    class Inhabitant//居民类
    {
        public string ID { get; set; }
        public string Name { get; set; }
        public string Birthday { get; set; }
        public void DisplayInha()
        {
            Console.WriteLine("\n身份证号:" + ID + "\n姓名:" + Name + "\n出生日期:" + Birthday);
        }
    }
    class Adult:Inhabitant//成人类
    { 
        public string Degree { get; set; }
        public string Occupation { get; set; }
        public void DisplayAdult()
        {
            Console.WriteLine("\n学历:" + Degree + "\n职业:" + Occupation);
        }
    }
    class Officials:Adult//官员类
    {
        public string Party { get; set; }
        public string Office { get; set; }
        public void DisplayOffic()
        {
            Console.WriteLine("\n党派:" + Party + "\n职务:" + Office);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("我是叶豪方，这是我的课后作业4");
            Officials O1 = new Officials();
            O1.ID = "12345678";
            O1.Name = "马飞";
            O1.Birthday = "19980921";
            O1.Degree = "大专";
            O1.Occupation = "学生";
            O1.Party = "团员";
            O1.Office = "团支书";
            O1.DisplayInha();
            O1.DisplayAdult();
            O1.DisplayOffic();
        }
    }
}
